package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.BankBillJd0028Mapper;
import com.xyy.saas.payment.dao.model.BankBillJd0028;
import com.xyy.saas.payment.dao.model.BankBillJd0028QueryParam;
import com.xyy.saas.payment.service.BankBillJd0028Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 新分账商户根据交易时间生成交易流水表-shareOrderCreate(BankBillJd0028)表服务实现类
 *
 * @author chujian
 * @since 2023-06-13 15:06:34
 */
@Slf4j
@Service
public class BankBillJd0028ServiceImpl implements BankBillJd0028Service {
    @Resource
    private BankBillJd0028Mapper bankBillJd0028Mapper;

    @Override
    public List<BankBillJd0028> queryIncompleteBill(Date billDate) {
       return bankBillJd0028Mapper.queryIncompleteBill(billDate);
    }
    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BankBillJd0028 queryById(Long id) {
        return this.bankBillJd0028Mapper.queryById(id);
    }

    /**
     * 查询总数
     * @param param 查询条件
     * @return
     */
    @Override
    public long total(BankBillJd0028QueryParam param) {
        if (null == param) {
            param = new BankBillJd0028QueryParam();
        }
        if (!StringUtils.isEmpty(param.getDealTimeEnd()) && param.getDealTimeEnd().trim().length() <= 10) {
            param.setDealTimeEnd(param.getDealTimeEnd().trim() + " 23:59:59");
        }
        return bankBillJd0028Mapper.total(param);
    }

    /**
     * 查询指定行数据
     *
     * @param param 查询条件
     * @return 对象列表
     */
    @Override
    public List<BankBillJd0028> queryPage(BankBillJd0028QueryParam param) {
        if (null == param) {
            param = new BankBillJd0028QueryParam();
        }
        if (!StringUtils.isEmpty(param.getDealTimeEnd()) && param.getDealTimeEnd().trim().length() <= 10) {
            param.setDealTimeEnd(param.getDealTimeEnd().trim() + " 23:59:59");
        }
        param.setOffset(((param.getPage() == 0 ? 1 : param.getPage()) - 1) * param.getPageSize());
        return bankBillJd0028Mapper.queryPageV2(param);
    }

    /**
     * 查询指定行数据
     *
     * @param param 查询条件
     * @return 对象列表
     */
    @Override
    public List<BankBillJd0028> queryExport(BankBillJd0028QueryParam param) {
        if (null == param) {
            param = new BankBillJd0028QueryParam();
        }
        if (!StringUtils.isEmpty(param.getDealTimeEnd()) && param.getDealTimeEnd().trim().length() <= 10) {
            param.setDealTimeEnd(param.getDealTimeEnd().trim() + " 23:59:59");
        }
        return bankBillJd0028Mapper.queryExport(param);
    }

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<BankBillJd0028> 实例对象列表
     * @return 影响行数
     */
    @Override
    public int insertBatch(List<Object> entities) {
        if (CollectionUtils.isEmpty(entities)) {
            return 0;
        }
        return bankBillJd0028Mapper.insertBatch(entities);
    }
    public int updateBatch(List<BankBillJd0028> entities) {
        if (CollectionUtils.isEmpty(entities)) {
            return 0;
        }
        return bankBillJd0028Mapper.updateBatch(entities);
    }
    /**
     * 通过主键删除数据
     *
     * @param bankBillJd0028 实例对象
     * @return 影响行数
     */
    @Override
    public int delete(BankBillJd0028 bankBillJd0028) {
        return bankBillJd0028Mapper.delete(bankBillJd0028);
    }
    
}
